home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11980 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: victor2.vv.cta.com!usenet
  2. From: Daron Baird <daron@rc.cta.com>
  3. Newsgroups: comp.unix.programmer,comp.unix.questions,comp.unix.misc,comp.lang.c,comp.sys.hp.hpux
  4. Subject: How to determine type of connection from file descriptor
  5. Date: 27 Mar 1996 22:18:15 GMT
  6. Organization: cta
  7. Message-ID: <4jcer7$ck@victor2.vv.cta.com>
  8. NNTP-Posting-Host: pc13.rc.cta.com
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 1.22 (Windows; I; 16bit)
  13.  
  14. I need to write a routine that can determine what type of connection a 
  15. file descriptor represents, tcp, udp, or serial.  I am running HPUX 9.07 
  16. on a HP9000. The language is C.
  17.  
  18. The pseudo code would look like the following:
  19.  
  20. routine1(fd)
  21.  int fd;
  22.  
  23. {
  24.   if fd is connected to a serial port then
  25.      call serial_port_function
  26.   else if fd is connected to a TCP port then
  27.      call tcp_function
  28.   else if fd is connected to a UDP port then
  29.      call udp_function
  30.   endif
  31.  
  32. }
  33.  
  34. The question that I have is: how does one determine from the file 
  35. descriptor what type of connection it represents.  Is there an ioctl like 
  36. call that can determine this information?
  37.  
  38.  
  39.